home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1036 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.0 KB  |  71 lines

  1. Path: news.sunquest.com!kitk!kitk
  2. From: kitk@mudshark.sunquest.com (Kit Kauffmann)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: HELP: Calling functions from DLLs
  5. Date: Mon, 8 Jan 1996 15:04:05
  6. Organization: Sunquest
  7. Distribution: world
  8. Message-ID: <kitk.2047.000F11DE@mudshark.sunquest.com>
  9. References: <1996Jan8.194827.23308@zippy.dct.ac.uk>
  10. NNTP-Posting-Host: kkauffma.sunquest.com
  11. X-Newsreader: Trumpet for Windows [Version 1.0 Rev A]
  12.  
  13. In article <1996Jan8.194827.23308@zippy.dct.ac.uk> ds11@st-and.ac.uk (Darren Steers) writes:
  14. >Subject: HELP: Calling functions from DLLs
  15. >From: ds11@st-and.ac.uk (Darren Steers)
  16. >Date: 8 Jan 96 19:48:27 GMT
  17.  
  18. >Hi,
  19.  
  20. >Can you help?  I have been supplied with a DLL (not source code) 
  21. >from a third party. It was compiled using MS Visual C++.
  22.  
  23. >I am using Borland C++ 4.5 and am having problems calling the functions
  24. >from the third party DLL.
  25.  
  26. >When I wrote a simple test DLL (Beep.cpp) the function prototype and
  27. >declaration were like this (From a book)
  28.  
  29. >     void _FAR _EXPFUNC MakeBeep (int iCount);
  30.  
  31. >This worked great and I could use the function in my application 
  32. >(CallBeep.cpp) to my hearts content.
  33.  
  34. >HOWEVER,  the 3rd party DLL had its functions declared in this style
  35.  
  36. >     void FAR PASCAL MakeBeep (int iCount);
  37.  
  38. >When I try to use this function I get this error message
  39.  
  40. >     Linker Error: Undefined symbol MakeBeep(int) in module CALLBEEP.CPP
  41.  
  42. >Can I get my application to recognise functions declared in the FAR PASCAL
  43. >format, or do I need to get the source code and change the function
  44. >prototypes and definitions to _FAR _EXPFUNC ????
  45.  
  46. >Thanks for any help.
  47.  
  48. >Darren Steers
  49.  
  50. >University of St Andrews
  51. >Scotland
  52.  
  53. >ds11@st-and.ac.uk
  54.  
  55. try:
  56.  
  57. extern "C"
  58. {
  59.     void MakeBeep();
  60. }
  61.  
  62. so the compiler knows the function is a "C" function (of course, if it was 
  63. compiled as a C++ function, you are SOL, since VC and BC use different name 
  64. mangling techniques)
  65.  
  66.  
  67. Kit Kauffmann - kitk@mudshark.sunquest.com
  68. AKA 73363,447 (Compu$erve)
  69.  
  70. Finger me for my public key
  71.